#include "..\include\socket.hpp"
#include <iostream>

using namespace std;

#define DEFAULT_PORT 27015

int main(int argc, char **argv)
{
    // Validate the parameters
    if (argc != 2)
    {
        cerr << "usage: " << argv[0] << " server-name" << endl;
        return 1;
    }

    try
    {
        WSA wsa;

        client_t client;

        client.connect(argv[1], DEFAULT_PORT, SOCK_TYPE::TCP);
        int n = client.send("this is a test");
        cout << "Bytes Sent: " << n << endl;
        client.shutdown(false, true);
        auto r = client.recv();
        cout << "Bytes received: " << r.size() << endl;
        return 0;
    }
    catch (const char *s)
    {
        cerr << s << endl;
    }
    catch (std::string s)
    {
        cerr << s << endl;
    }
    return 1;
}